﻿using System.Drawing;
using System.Linq;
using System.Collections.Generic;

namespace TowerDefense_MLP
{
    abstract class Enemy
    {
        #region ATTRIBUTES

        protected int _Life;
        private int _Speed;

        protected int _RewardValue;
        protected int _PathIndex;
        protected Point _Position;
        protected int _MoveDalay;
        protected int _iterator;
        protected Bitmap _Image;
        protected TOWER_TYPE _hitBy;
        
        #endregion

        #region METHODS

        #region Getters/Setters

        public int Speed
        {
            get { return _Speed; }
            set { _Speed = value; }
        }
        public int PathIndex
        {
            get { return this._PathIndex; }
        }
        public Point Position
        {
            get { return this._Position; }
            set { this._Position = value; }
        }
        public Bitmap Image
        {
            get { return this._Image; }
        }
        public int Life
        {
            get { return this._Life; }
            set { this._Life = value; }
        }
        public int RewardValue
        {
            get { return this._RewardValue; }
        }
        public TOWER_TYPE HitBy
        {
            get { return this._hitBy; }
            set { this._hitBy = value; }
        }

        #endregion

        public Enemy Move(List<Point> path)
        {
            this._iterator--;
            this._hitBy = TOWER_TYPE.NONE;

            if (this._iterator == 0) // hora de mover
            {
                this._PathIndex += this.Speed;
                this._iterator = this._MoveDalay;

                if (this._PathIndex < path.Count)
                    this._Position = path[this._PathIndex];
                else
                    this.Position = path.Last();
            }

            return this;
        }

        #endregion
    }

    class OrcShaman : Enemy
    {
        public OrcShaman(int linePos)
        {
            this._Life = 100;
            this.Speed = 12;
            this._RewardValue = 3;
            this._PathIndex = -this.Speed;
            this._MoveDalay = 6;
            this._Position = new Point(-1, -1);
            this._iterator = (1+linePos)*this.Speed - 1;
            this._Image = new Bitmap(@"Images\enemy3.png");
            this._hitBy = TOWER_TYPE.NONE;
        }
    }

    class Troll : Enemy
    {
        public Troll(int linePos)
        {
            this._Life = 200;
            this.Speed = 14;
            this._RewardValue = 5;
            this._PathIndex = -this.Speed;
            this._MoveDalay = 7;
            this._Position = new Point(-1, -1);
            this._iterator = (1 + linePos) * this.Speed - 1;
            this._Image = new Bitmap(@"Images\enemy1.png");
            this._hitBy = TOWER_TYPE.NONE;
        }
    }

    class Warrior : Enemy
    {
        public Warrior(int linePos)
        {
            this._Life = 400;
            this.Speed = 10;
            this._RewardValue = 8;
            this._PathIndex = -this.Speed;
            this._MoveDalay = 5;
            this._Position = new Point(-1, -1);
            this._iterator = (1 + linePos) * this.Speed - 1;
            this._Image = new Bitmap(@"Images\enemy2.png");
            this._hitBy = TOWER_TYPE.NONE;
        }
    }

    class Dragon : Enemy
    {
        public Dragon(int linePos)
        {
            this._Life = 800;
            this.Speed = 20;
            this._RewardValue = 13;
            this._PathIndex = -this.Speed;
            this._MoveDalay = 8;
            this._Position = new Point(-1, -1);
            this._iterator = (1 + linePos) * this.Speed - 1;
            this._Image = new Bitmap(@"Images\enemy5.png");
            this._hitBy = TOWER_TYPE.NONE;
        }
    }
}
